# SPDX-License-Identifier: GPL-2.0
%YAML 1.2
---
$id: http://devicetree.org/schemas/media/i2c/ovti,ov5640.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: OmniVision OV5640 Image Sensor

maintainers:
  - Steve Longerbeam <slongerbeam@gmail.com>

allOf:
  - $ref: /schemas/media/video-interface-devices.yaml#

properties:
  compatible:
    const: ovti,ov5640

  reg:
    maxItems: 1

  clocks:
    description: XCLK Input Clock

  clock-names:
    const: xclk

  AVDD-supply:
    description: Analog voltage supply, 2.8 volts

  DVDD-supply:
    description: Digital core voltage supply, 1.5 volts

  DOVDD-supply:
    description: Digital I/O voltage supply, 1.8 volts

  powerdown-gpios:
    maxItems: 1
    description: >
      Reference to the GPIO connected to the powerdown pin, if any.

  reset-gpios:
    maxItems: 1
    description: >
      Reference to the GPIO connected to the reset pin, if any.

  rotation:
    enum:
      - 0
      - 180

  port:
    description: Digital Output Port
    $ref: /schemas/graph.yaml#/$defs/port-base
    additionalProperties: false

    properties:
      endpoint:
        $ref: /schemas/media/video-interfaces.yaml#
        unevaluatedProperties: false

        properties:
          clock-lanes:
            const: 0

          data-lanes:
            minItems: 1
            maxItems: 2
            items:
              enum: [1, 2]

          bus-width:
            enum: [8, 10]

          data-shift:
            enum: [0, 2]

required:
  - compatible
  - reg
  - clocks
  - clock-names
  - AVDD-supply
  - DVDD-supply
  - DOVDD-supply
  - port

additionalProperties: false

examples:
  - |
      #include <dt-bindings/clock/imx6qdl-clock.h>
      #include <dt-bindings/gpio/gpio.h>

      i2c {
          #address-cells = <1>;
          #size-cells = <0>;

          camera@3c {
              compatible = "ovti,ov5640";
              pinctrl-names = "default";
              pinctrl-0 = <&pinctrl_ov5640>;
              reg = <0x3c>;
              clocks = <&clks IMX6QDL_CLK_CKO>;
              clock-names = "xclk";
              DOVDD-supply = <&vgen4_reg>; /* 1.8v */
              AVDD-supply = <&vgen3_reg>;  /* 2.8v */
              DVDD-supply = <&vgen2_reg>;  /* 1.5v */
              powerdown-gpios = <&gpio1 19 GPIO_ACTIVE_HIGH>;
              reset-gpios = <&gpio1 20 GPIO_ACTIVE_LOW>;
              rotation = <180>;

              port {
                  /* MIPI CSI-2 bus endpoint */
                  ov5640_to_mipi_csi2: endpoint {
                      remote-endpoint = <&mipi_csi2_from_ov5640>;
                      clock-lanes = <0>;
                      data-lanes = <1 2>;
                  };
              };
          };
      };

  - |
      i2c {
          #address-cells = <1>;
          #size-cells = <0>;

          camera@3c {
              compatible = "ovti,ov5640";
              pinctrl-names = "default";
              pinctrl-0 = <&pinctrl_ov5640>;
              reg = <0x3c>;
              clocks = <&clk_ext_camera>;
              clock-names = "xclk";
              DOVDD-supply = <&vgen4_reg>; /* 1.8v */
              AVDD-supply = <&vgen3_reg>;  /* 2.8v */
              DVDD-supply = <&vgen2_reg>;  /* 1.5v */

              port {
                  /* Parallel bus endpoint */
                  ov5640_to_parallel: endpoint {
                      remote-endpoint = <&parallel_from_ov5640>;
                      bus-width = <8>;
                      data-shift = <2>; /* lines 9:2 are used */
                      hsync-active = <0>;
                      vsync-active = <0>;
                      pclk-sample = <1>;
                  };
              };
          };
      };

...
